Closed Bug 1847712 Opened 2 years ago Closed 1 month ago

Should SVG's `<script>` element support the `fetchpriority` attribute analogous to HTML's `<script>` element?

Categories

(Core :: Networking, enhancement, P3)

enhancement

Tracking

()

RESOLVED FIXED
140 Branch

People

(Reporter: mbrodesser, Assigned: fredw)

References

(Blocks 1 open bug)

Details

(Keywords: dev-doc-needed, Whiteboard: [necko-triaged], [wptsync upstream])

Attachments

(4 files)

Since we already support async, defer and module for SVG script elements perhaps we should just support fetchpriority too.

(In reply to Robert Longson [:longsonr] from comment #1)

Since we already support async, defer and module for SVG script elements perhaps we should just support fetchpriority too.

Yes, that's possible too.

Is there actually demand for it?

Summary: Use `fetchpriority="auto"` for SVGs `<script>` elements → Use `fetchpriority="auto"` for SVGs `<script>` elements?

Probably not much yet given Chrome doesn't support any of this but someone has to go first.

Severity: -- → S3
Priority: -- → P3
Whiteboard: [necko-triaged]
See Also: → 1865837

This commit adds tests for the following cases, setting the expectations
to current behavior.

  1. SVG element <script async>
  2. SVG element <script defer>
  3. Dymically inserted SVG <script> element.

The fetchpriority attribute is currently not defined for SVG
<script> and a fortiori not implemented, so it does not influence
the internal priority.

The two first cases execute speculative parsing, but contrary to HTML
the async/defer attributes are not parsed and corresponding properties
considered false [1] so they don't influence the internal priority,
which remains PRIORITY_NORMAL.

The third case triggers non-speculative and is loaded asynchronously
so the internal priority is PRIORITY_LOW, just like HTML.

[1] https://searchfox.org/mozilla-central/rev/9bb5d5f55da6cc7163dd93825c25609b769822f9/parser/html/nsHtml5TreeBuilderCppSupplement.h#587

Assignee: nobody → fwang
Status: NEW → ASSIGNED

This commit adds fetchpriority tests for in-body SVG <script> elements.
Since the fetchpriority attribute is not specified on such elements,
and a fortiori not implemented, it has no effect on the internal
priority. Since we don't distinguish between "early" or "late" scripts
(bug 1872654) that internal priority always remains equal to
PRIORITY_NORMAL. We set expectations to current behavior.

This patch is similar to D201676 but for type="module" SVG <scripts>.
The difference is that speculative parsing for SVG does take into account
the type attribute so they are assigned PRIORITY_HIGH when fetchpriority
is enabled (and remains PRIORITY_NORMAL otherwise).

(In reply to Robert Longson [:longsonr] from comment #1)

Since we already support async, defer and module for SVG script elements perhaps we should just support fetchpriority too.

FWIW I did some testing (see attached patches) and, in addition to ignoring the fetchpriority attribute, the differences seem to be:

(1) It is not possible to have SVG script the in head element when initially parsing the document via the HTML5 parser (unless I'm missing something?)
(2) async/defer attributes are not taken into account when doing speculative parsing. I wonder whether we should fix that?

(In reply to Frédéric Wang (:fredw) from comment #7)

(In reply to Robert Longson [:longsonr] from comment #1)

Since we already support async, defer and module for SVG script elements perhaps we should just support fetchpriority too.

FWIW I did some testing (see attached patches) and, in addition to ignoring the fetchpriority attribute, the differences seem to be:

(1) It is not possible to have SVG script the in head element when initially parsing the document via the HTML5 parser (unless I'm missing something?)

I don't think you're missing anything.

(2) async/defer attributes are not taken into account when doing speculative parsing. I wonder whether we should fix that?

I imagine we should fix that.

(In reply to Robert Longson [:longsonr] from comment #8)

(2) async/defer attributes are not taken into account when doing speculative parsing. I wonder whether we should fix that?

I imagine we should fix that.

FWIW, I believe this would be a straightforward fix at the place Mirko already left a comment: https://searchfox.org/mozilla-central/rev/9bb5d5f55da6cc7163dd93825c25609b769822f9/parser/html/nsHtml5TreeBuilderCppSupplement.h#564

Depends on: 1880046
Summary: Use `fetchpriority="auto"` for SVGs `<script>` elements? → Should SVG's `<script>` element support the `fetchpriority` attribute analogous to HTML's `<script>` element?

After bug 1880433, the SVG script would all default to normal priority when fetchpriority is enabled, so we can land these patches without waiting for the fix to bug 1880046.

Keywords: leave-open
Pushed by fwang@igalia.com: https://hg.mozilla.org/integration/autoland/rev/0601f60bf3a9 Add fetchpriority test for async/defer/dynamic SVG <script>. r=valentin,necko-reviewers https://hg.mozilla.org/integration/autoland/rev/134715b8ebc0 Add fetchpriority test for in-body SVG <script>. r=valentin,necko-reviewers https://hg.mozilla.org/integration/autoland/rev/bfe11ef18e9e Add fetchpriority test for async/defer/dynamic SVG module scripts. r=valentin,necko-reviewers

The leave-open keyword is there and there is no activity for 6 months.
:smayya, maybe it's time to close this bug?
For more information, please visit BugBot documentation.

Flags: needinfo?(smayya)
Flags: needinfo?(smayya)
Pushed by longsonr@gmail.com: https://hg.mozilla.org/integration/autoland/rev/63b702867240 support fetchpriority for SVG image, feImage and script elements r=emilio

Backed out for causing wpt failures @ttr-image-fetchpriority.html and @attr-script-fetchpriority.html.

Flags: needinfo?(fwang)
Flags: needinfo?(fwang)
Pushed by longsonr@gmail.com: https://hg.mozilla.org/integration/autoland/rev/1fca73aea236 support fetchpriority for SVG image, feImage and script elements r=emilio
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/52232 for changes under testing/web-platform/tests
Whiteboard: [necko-triaged] → [necko-triaged], [wptsync upstream]
Upstream PR merged by moz-wptsync-bot
Status: ASSIGNED → RESOLVED
Closed: 1 month ago
Resolution: --- → FIXED

fetchpriority is now implemented on SVGScriptElement.webidl, SVGImageElement.webidl and SVGFEImageElement.webidl.
SVG script, image and feImage elements now work the same as HTML script and img elements in supporting fetchpriority. I.e. https://developer.mozilla.org/en-US/docs/Web/API/HTMLScriptElement/fetchPriority

Target Milestone: --- → 140 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: